// MusicPlayerWidget.h
#ifndef MUSICPLAYERWIDGET_H
#define MUSICPLAYERWIDGET_H

#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QListWidget>
#include <QPushButton>
#include <QSlider>
#include <QLabel>
#include <QMediaPlayer>
#include <QAudioOutput>
#include <QFileDialog>
#include <QTime>
#include <QUrl>

class MusicPlayerWidget : public QWidget
{
    Q_OBJECT

public:
    explicit MusicPlayerWidget(QWidget* parent = nullptr);
    ~MusicPlayerWidget();

private slots:
    void addSongsToPlaylist();
    void playSelectedSong();
    void playPause();
    void playNext();
    void playPrevious();
    void updatePlaybackPosition(qint64 position);
    void updateDuration(qint64 duration);
    void seekPosition(int position);
    void updatePlaybackStatus();
    void updateCurrentSongInfo();

private:
    void setupUI();
    void setupConnections();

    QMediaPlayer* mediaPlayer;
    QAudioOutput* audioOutput;

    // UI Elements
    QVBoxLayout* mainLayout;
    QHBoxLayout* controlLayout;
    QHBoxLayout* infoLayout;

    QListWidget* playlistWidget;
    QListWidget* requestListWidget;

    QPushButton* addSongsButton;
    QPushButton* playPauseButton;
    QPushButton* nextButton;
    QPushButton* previousButton;
    QPushButton* addToRequestButton;

    QSlider* progressSlider;
    QSlider* volumeSlider;

    QLabel* currentSongLabel;
    QLabel* currentTimeLabel;
    QLabel* totalTimeLabel;

    int currentPlaylistIndex;
    bool isPlaying;
};

#endif // MUSICPLAYERWIDGET_H

